import pageination from '../../components/pageination/pageination.vue'
export default {
	//数据
  data() {
    return {
      curId: 0,
      total: 0, //总条数
      page: 1, //当前页
      size: 4, //每页显示条数
      portalMainImgUrl: "", //门户主图
      portalSecondImgUrl: "", //门户次图
      policyReleaseList: [], //政策集合信息
      fatherIndex:0, //一级菜单下标
      childIndex:0,//二级菜单下标
    }
  },
	components: {
		pageination
	},
	created() { //调用方法
		//初始化分页信息
		this.searchTodo();

    let that = this;
    //初始化门户图片信息
    that.$post(
      that.urls.getAllPortalConfigList, {
        "type": 0
      }
    )
    .then(function(res) {
      if(res.success) {
        let portalConfigList = res.data;
        for(let i = 0, len = portalConfigList.length; i < len; i++) {
          if(portalConfigList[i].baseType == 0) {
            that.portalMainImgUrl = portalConfigList[i].url; //门户主图
          } else if(portalConfigList[i].baseType == 1) {
            that.portalSecondImgUrl = portalConfigList[i].url; //门户次图
          }
        }
      }
    })
	},
	mounted() {


	},
	updated:function(){
		if(this.getParamValue("fatherIndex")){
			this.fatherIndex=this.getParamValue("fatherIndex");
		}
		if(this.getParamValue("childIndex")){
			this.childIndex=this.getParamValue("childIndex");
		}
	},
	methods: { //写函数方法
		//页码切换执行方法
		pageFn: function(val, pid) {
			this.page = parseInt(val);
			//此处调列表数据接口
			this.searchTodo(pid); //查询新闻
		},
		/**返回子组件用户选择的一页显示条数**/
		obtainChild: function(data) {
			this.row = data;
		},
		//搜索数据列表
		searchTodo: function() {
			let that = this;
			that.$post(
					that.urls.getPolicyReleasePageInfo, {
						"pageNum": that.page,
						"pageSize": that.size,
						"type": 0
					}
				)
				.then(function(res) {
					if(res.success) {
						that.policyReleaseList = res.pageInfo.list;
						that.total = res.pageInfo.total;
						that.page = res.pageInfo.pageNum;
					}
				})
		},
		//打开政策详情
		NewsDetails: function(uuid) {
			if(uuid != null && uuid != "") {
				this.set("policyDetailsid", uuid);
				this.$router.push({
					path: "policyDetails?fatherIndex="+this.fatherIndex+"&childIndex="+this.childIndex,
				})
			}
		},
	}
}
